Release 10.1A: OpenEdge Development:
Debugging and Troubleshooting


Query statistics

Query statistics provide information on the query as it extracts data from the database, that is, on the retrieval of records during the query. This information is intended to help you evaluate query performance.

For the purposes of gathering statistics, queries fall into either of two categories:

Query Info logging logs different information depending on whether the query is a pre-pass query or a non-pre-pass query. Both pre-pass and non-pre-pass queries write statistics when the query is complete. A query is considered complete at the following points in the code:

Query statistics for pre-pass queries

OpenEdge provides two sets of query statistics for pre-pass queries: first, when OpenEdge builds the result-list; second when the query is complete, that is, at the end of the block, or when OpenEdge closes the query.

OpenEdge logs the following query statistics when it completely builds the result-list for a pre-pass query:

OpenEdge logs the following query statistics when the pre-pass query is complete:

Query statistics for non-pre-pass queries

OpenEdge provides a single set of statistics for non-pre-pass queries at query completion. Query Info logging logs the following query statistics when the query is complete:

Query preparation statistics

Query preparation determines how OpenEdge will access the requested data, for example, which indices to use. The compiler prepares statically opened queries at compile time. OpenEdge prepares dynamically opened queries at run time, using the QUERY-PREPARE() method.

Because preparation of a dynamically opened query can have an impact on performance, Query Info logging tracks the following statistics on dynamically opened queries:

Number of records sent by the server

The server, in resolving a query, sends a number of records to the client. In certain cases, the client determines whether a record satisfies selection criteria. If a query returns a large number of records, only a few of which the client determines satisfy the selection criteria, the query might be inefficient.

For each table in a query, Query Info logging tracks:

Optimizations within the client and database server might skew the figures somewhat, as in the cases when the server returns to the client field lists rather than a full record, or a prefetched list of records.

Use these figures with other statistical data to determine if a query is inefficient.

Number of records available to the 4GL

It is useful to know the number of records available to the 4GL:

Consider this figure in light of other statistical data, such as blocks accessed, or records sent by the server, to determine the efficiency of the query. For example:

Time taken to build a result-list

It is useful to know how long it takes to build a result-list for a pre-pass query, in evaluating query efficiency. Using this value in combination with other statistical data, such as the number of entries in a result-list, the number of records read, and database block access, you can calculate your own query averages, for example, average time a record is available to the 4GL, or average time for a record to be sent to the client.

Field list information

Defining field lists in a query improves performance to remote databases and dataservers. The 4GL compiler may further optimize the query by adding implicit fields to the field lists or use an implicit field list if the user did not specify one. Query Info logging logs all field lists a query uses as part of the Query Statistics. Each field list is logged with the table to which it applies.

For more information on field lists, see OpenEdge Development: Programming Interfaces .

Database block access

When evaluating query efficiency, it is useful to consider the number of times the server performs database block accesses on behalf of the client. A disparity in the number of accesses to records returned could indicate poor index selection. OpenEdge tracks database block access on OpenEdge RDBMSs (but not on dataservers) in the _userio-dbaccess field of the _userio Virtual System Table:

A large number of database block accesses do not necessarily indicate a poorly conceived query. The number stored in the _userio-dbaccess field is a combined figure that includes both RM (data) and index block accesses. Although a high count on index accesses might predictably indicate inefficiencies in index use, a high count on RM accesses might simply mean that records are scattered throughout the database rather than in contiguous blocks. Thus, you have to weigh this value with other statistical data to determine query efficiency.

Note: Although not recommended, it is possible for a query to access tables in more than one database. For any such queries, OpenEdge records block access statistics for each database accessed. OpenEdge does not, however, track block access statistics for databases in single-user mode.

Read Access Statistics

Query Info Logging captures table and index read access statistics for each table and index identified in a query against an OpenEdge database. Read access statistics includes reads by all users connected to the database.

Note: Query Info logging omits read access statistics for DataServers and temp-tables. Additionally, read access statistics are not logged for preparing a dynamic query.

Table read access statistics provide the number of times read access has occurred on a table. Use Base Table (-basetable) with Table Range Size (-tablerangesize) to specify the range of tables for which you want to collect statistics. Table statistics are stored in the _TableStat-Read field of the _TableStat Virtual System Tables (VST).

Index read access statistics provide the number of times read access has occurred on an index. Use Base Index (-baseindex) with Index Range Size (-indexrangesize) to specify the range of indexes for which you want to collect statistics. Index statistics are stored in the _IndexStat-Read field of the _IndexStat VST.

Read access statistics information is located in the Query Statistics after the DB Block access statistics. For each table in the query, or a non-pre-pass query, the client writes the read access statistics in the Query Statistics once the query completes. For a pre-pass query, the client writes the read access statistics in the Query Statistics for building the results list, and again once the query completes. This differentiates the read accesses required to build the result list from those required to iterate through the list.

In order to get the table and index read statistics, the user must ensure the queried tables and indices are within the ranges specified by the startup parameters Base Table (-basetable)/Table Range Size (-tablerangesize) and Base Index (-baseindex)/Index Range Size (-indexrangesize) ranges. If your query accesses tables or indices outside these ranges, Query Info logging cannot determine the access statistics for the tables or indices, and displays “UNAVAILABLE” for the read access statistics.

For more information on the referenced startup parameters, see OpenEdge Deployment: Startup Command and Parameter Reference . For more information on VSTs, see OpenEdge Data Management: Database Administration .


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095